package com.xul.yygh.hosp.controller;

import com.xul.yygh.common.result.Result;
import com.xul.yygh.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import model.com.xul.yygh.model.hosp.Hospital;
import model.com.xul.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author xul
 * @create 2021-07-11 19:08
 */

@Api(tags = "医院管理接口")
@RestController
@RequestMapping("admin/hosp/hospital")
// @CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院列表分页接口
     *
     * @param page
     * @param limit
     * @param hospitalQueryVo
     * @return
     */
    @ApiOperation("医院列表分页接口")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.findPageHospital(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    /**
     * 更新上线状态
     *
     * @param id
     * @param status
     * @return
     */
    @ApiOperation("更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id,
                               @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    /**
     * 医院详情信息
     * @param id
     * @return
     */
    @ApiOperation("医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String, Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
}
